package launcher.simple.android.woblog.cn.simplelauncher;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;

import java.util.ArrayList;

import cn.woblog.android.common.utils.DimensionUtils;
import cn.woblog.android.common.utils.MyLog;
import cn.woblog.android.common.utils.activity.BaseActivity;
import launcher.simple.android.woblog.cn.adapter.RootAdapter;
import launcher.simple.android.woblog.cn.fragment.AppFragment;
import launcher.simple.android.woblog.cn.fragment.HomeFragment;


public class MainActivity extends BaseActivity {

    private ViewPager vp_root;

    private RootAdapter rootAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void initViews() {
        super.initViews();
        DimensionUtils.init(getActivity());
        vp_root = (ViewPager) findViewById(R.id.vp_root);
    }

    @Override
    protected void initDatas() {
        super.initDatas();
        rootAdapter = new RootAdapter(getActivity(), getSupportFragmentManager());
        vp_root.setAdapter(rootAdapter);

        ArrayList<Fragment> integers = new ArrayList<>();
        integers.add(new AppFragment());
        integers.add(new HomeFragment());
        rootAdapter.setDatas(integers);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        MyLog.d("onKeyDown:"+keyCode);
        return super.onKeyDown(keyCode, event);
    }
}
